/**
 * Copyright (C), 2001-2031, www.bosssof.com.cn
 * FileName: AppUtils.java
 * Author: shixianwei
 * Date: 2024/8/13 20:31
 * Description:
 * <p>
 * History:
 * Date          Author   Version  Desc
 * 2024-01-01    bosssoft  1.0.0   initialize this file
 */
package com.bosssoft.setp.utils;

import com.bosssoft.setp.pojo.vo.CommonResponse;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @className: AppUtils
 * @description:
 * 应用程序相关的工具方法定义在这里，例如版本获取，全部应答报文设置等
 * @author: shixianwei
 * @date: 2024/8/13 20:31
 * @since 1.0
 **/
@Component
public class AppUtils {

    private AppUtils() {
        // prevent construct
    }

    /**
     * 从配置文件获取后端的程序版本
     */
    @Value("1.0.0")
    private String version;
    /**
     * 存储后端程序版本
     */
    private static String myVersion;

    @PostConstruct
    public void init() {
        AppUtils.myVersion = version;
    }

    /**
     *  对统一应答设置版本
     * @param commonResponse 统一应答
     * @param <T>
     */
    public static <T> void setResponseExtendInfo(CommonResponse<T> commonResponse) {
        commonResponse.getHead().setVersion(myVersion);
    }
}

